package com.mini.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mini.entity.Result;
import com.mini.entity.ScienceFuck;
import com.mini.entity.VaccineUserInfo;
import com.mini.service.ScienceFuckService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hy
 * @since 2021-05-08
 */
@RestController
@CrossOrigin
@RequestMapping("/mini/t-science-fuck")
public class ScienceFuckController {
    @Autowired
    private ScienceFuckService scienceFuckService;

    @GetMapping("/find/{current}/{size}/{flag}")
    @ApiOperation(value = "查,1为接种详情，2为不适人群")
    public Result select(@PathVariable(value = "current", required = true) Integer current,
                         @PathVariable(value = "size", required = true) Integer size,
                         @PathVariable(value = "flag", required = true) Integer flag) {
        QueryWrapper<ScienceFuck> wrapper = new QueryWrapper<>();
        wrapper.eq("flag", flag);
        Page<ScienceFuck> page = new Page<>(current, size);
        scienceFuckService.page(page, wrapper);
        return Result.success().data(page);
    }

    @PostMapping()
    @ApiOperation(value = "增")
    public Result save(@RequestBody ScienceFuck scienceFuck) {
        return scienceFuckService.save(scienceFuck) ? Result.success() : Result.error();
    }
}

